package com.ssyc.gsk_teacher_appraisal.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ssyc.common.utils.SPUtil;
import com.ssyc.gsk_teacher_appraisal.R;
import com.ssyc.gsk_teacher_appraisal.activity.TkTeacherAppraisalQuestionActivity;
import com.ssyc.gsk_teacher_appraisal.bean.ChooseTestInfo;
import com.ssyc.gsk_teacher_appraisal.constant.TeacherAppKeys;

import java.util.List;

/**
 * 选择套题列表的适配器
 * Created by Kevin on 2018/10/24.
 */

public class ChooseTestRvAdapter extends BaseItemDraggableAdapter<ChooseTestInfo.ListBean, BaseViewHolder> {
    private Context context;

    public ChooseTestRvAdapter(Context context, int layoutResId, List<ChooseTestInfo.ListBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, ChooseTestInfo.ListBean item) {

        //设置标题
        helper.setText(R.id.tv_name, item.getTag());

        //查看详情的布局
        LinearLayout ll = helper.getView(R.id.ll_details);
        ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //跳转到查看详情的界面
                // 2老师预览试卷(32号接口)
                SPUtil.put(context, TeacherAppKeys.AUTHERTYPE, 2);
                //跳转到查看详情的界面
                Intent intent = new Intent(context, TkTeacherAppraisalQuestionActivity.class);
                intent.putExtra("rowId", item.getRow_id());
                intent.putExtra("testName", item.getTag());
                context.startActivity(intent);

            }
        });
    }
}
